home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Tools / Mac / CWPPCProfiler / FWProfiler.cpp next >
Encoding:
Text File  |  1996-09-17  |  2.8 KB  |  107 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWProfiler.cpp
  4. //    Release Version:    $ ODF 2 $ 
  5. //
  6. //    Copyright:    (c) 1993-1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWPROFILER_H
  11. #include "FWProfiler.h"
  12. #endif
  13.  
  14. #ifndef __PROFILER__
  15. #include <Profiler.h>
  16. #endif
  17.  
  18. #ifndef __FOLDERS__
  19. #include <Folders.h>
  20. #endif
  21.  
  22. #include <string.h>
  23.  
  24. static Str255 gDumpFile;
  25.  
  26. //----------------------------------------------------------------------------------------
  27. // FW_ProfilerGetStatus
  28. //----------------------------------------------------------------------------------------
  29.  
  30. short FW_ProfilerGetStatus()
  31. {
  32.     return ProfilerGetStatus();
  33. }
  34.  
  35. //----------------------------------------------------------------------------------------
  36. // FW_ProfilerSetStatus
  37. //----------------------------------------------------------------------------------------
  38.  
  39. void FW_ProfilerSetStatus(short on)
  40. {
  41.     ProfilerSetStatus(on);
  42. }
  43.  
  44. //----------------------------------------------------------------------------------------
  45. // FW_ProfilerSetDumpFile
  46. //----------------------------------------------------------------------------------------
  47.  
  48. void FW_ProfilerSetDumpFile(ConstStr255Param newFile)
  49. {
  50.     memcpy(gDumpFile, newFile, newFile[0] + 1);
  51. }
  52.  
  53. //----------------------------------------------------------------------------------------
  54. // FW_ProfilerUseDefaultDumpFile
  55. //----------------------------------------------------------------------------------------
  56.  
  57. void FW_ProfilerUseDefaultDumpFile()
  58. {
  59.     short     bootVRefNum;
  60.     long    systemFolder;
  61.     OSErr    err;
  62.     Str255    newFile;
  63.     
  64.     static char gDefaultFile[] = "\pODFProfilerDump";
  65.     
  66.     newFile[0] = 0;
  67.     
  68.     err = FindFolder(kOnSystemDisk, kSystemFolderType, false, &bootVRefNum, &systemFolder);
  69.     if (err == noErr)
  70.     {
  71.         CInfoPBRec    cpb;
  72.         cpb.dirInfo.ioNamePtr = newFile;
  73.         cpb.dirInfo.ioVRefNum = bootVRefNum;
  74.         cpb.dirInfo.ioFDirIndex = -1;
  75.         cpb.dirInfo.ioDrDirID = 2;
  76.         
  77.         err = PBGetCatInfoSync(&cpb);
  78.         if (err == noErr)
  79.             newFile[++newFile[0]] = ':';
  80.     }
  81.     
  82.     memcpy(newFile + newFile[0] + 1, gDefaultFile + 1, gDefaultFile[0]); 
  83.     newFile[0] += gDefaultFile[0];
  84.     FW_ProfilerSetDumpFile(newFile);
  85. }
  86.  
  87. //----------------------------------------------------------------------------------------
  88. // FW_ProfilerDump
  89. //----------------------------------------------------------------------------------------
  90.  
  91. OSErr FW_ProfilerDump()
  92. {
  93.     if (!gDumpFile[0])
  94.         FW_ProfilerUseDefaultDumpFile();
  95.         
  96.     return ProfilerDump(gDumpFile);
  97. }
  98.  
  99. //----------------------------------------------------------------------------------------
  100. // FW_ProfilerClear
  101. //----------------------------------------------------------------------------------------
  102.  
  103. void FW_ProfilerClear()
  104. {
  105.     ProfilerClear();
  106. }
  107.